package com.cmower.baeldung.hashmap1;

/**
 * @author 沉默王二，一枚有趣的程序员
 */
public class Key {
    private final String value;

    public Key(String value) {
        this.value = value;
    }
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass())
            return false;
        Key key = (Key) o;
        return value.equals(key.value);
    }

    @Override
    public int hashCode() {
        if (value.startsWith("沉")) {
            return "沉".hashCode();
        }
        return value.hashCode();
    }
}
